//
//  WLSegmentView.m
//  LiveEducation
//
//  Created by Liu,Qingcan on 2017/4/16.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import "WLSegmentView.h"
@interface WLSegmentView()

@end
@implementation WLSegmentView

+(instancetype)segmentViewWithFrame:(CGRect)frame{
    return [[self alloc]initWithFrame:frame];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.showsVerticalScrollIndicator = YES;
        self.showsHorizontalScrollIndicator = NO;
        self.bounces = NO;
        self.pagingEnabled = YES;
    }
    return self;
}


#pragma public
- (void)showVCWithIndex:(NSInteger)index outsideVC:(UIViewController *)vc{
    CGFloat offX = self.frame.size.width;
    
    UIViewController *vcs = vc.childViewControllers[index];
    if (vcs.isViewLoaded) {
        return;
    }
    
    [self addSubview:vcs.view];
    vcs.view.frame = CGRectMake(offX*index, 0, self.frame.size.width, self.frame.size.height);
    
}


- (void)setVcArray:(NSArray *)vcArray{
    _vcArray = vcArray;
    self.contentSize = CGSizeMake(vcArray.count * self.frame.size.width, 0);
}


@end
